package com.xiaoma.tpo.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.StScore;

@Repository
public class StScoreDao extends BaseDaoImpl<StScore>{

    private static final Logger LOG = LoggerFactory.getLogger(StScoreDao.class);
    
    @SuppressWarnings("unchecked")
    public List<StScore> orderByScore(int planId, int groupId) {
        String sql = "SELECT * FROM st_score where st_plan_id = ? and st_group_id = ? ORDER BY score desc";
        LOG.info("SQL:{}; planId={} ; groupId={}", sql, planId, groupId);
        List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(StScore.class, getNameHandler()), planId, groupId);
        return (List<StScore>)result;
    }
}
